home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / buttons / toolb160 / sample / mdimain.frm < prev    next >
Text File  |  1995-02-12  |  17KB  |  554 lines

  1. VERSION 2.00
  2. Begin MDIForm frmMain 
  3.    Caption         =   "ToolBarPad"
  4.    ClientHeight    =   5040
  5.    ClientLeft      =   855
  6.    ClientTop       =   1785
  7.    ClientWidth     =   7740
  8.    Height          =   5730
  9.    Left            =   795
  10.    LinkTopic       =   "ToolBarPad"
  11.    Tag             =   "Select the entire text of the active file"
  12.    Top             =   1155
  13.    Width           =   7860
  14.    Begin StatusBar StatusBar1 
  15.       AdjustFieldHeight=   0   'False
  16.       Align           =   2  'Align Bottom
  17.       AutoToggle      =   -1  'True
  18.       CapsLockOffText =   ""
  19.       CapsLockOnText  =   "CAPS"
  20.       ExpandField     =   0
  21.       FieldProperties =   MDIMAIN.FRX:0000
  22.       FloodColor      =   &H00FF0000&
  23.       FloodField      =   -1
  24.       FloodInvertText =   0   'False
  25.       FloodPercent    =   0
  26.       FloodShowPct    =   -1  'True
  27.       Font3D          =   0  'none
  28.       Height          =   375
  29.       Left            =   0
  30.       LeftMargin      =   3
  31.       MenuTagsField   =   0
  32.       NumLockOffText  =   ""
  33.       NumLockOnText   =   "NUM"
  34.       RightMargin     =   3
  35.       ScrollLockOffText=   ""
  36.       ScrollLockOnText=   "SCRL"
  37.       Top             =   4665
  38.       Width           =   7740
  39.       Begin CommonDialog cmDialog 
  40.          Left            =   660
  41.          Top             =   120
  42.       End
  43.       Begin Label lblAction 
  44.          BackStyle       =   0  'Transparent
  45.          Height          =   135
  46.          Left            =   2280
  47.          TabIndex        =   4
  48.          Top             =   120
  49.          Visible         =   0   'False
  50.          Width           =   615
  51.       End
  52.    End
  53.    Begin ButtonBar ButtonBar1 
  54.       Align           =   1  'Align Top
  55.       ButtonColumns   =   4
  56.       ButtonPictures  =   MDIMAIN.FRX:05DD
  57.       ButtonProperties=   MDIMAIN.FRX:F5A7
  58.       ButtonRows      =   29
  59.       FontBold        =   0   'False
  60.       FontItalic      =   0   'False
  61.       FontName        =   "MS Sans Serif"
  62.       FontSize        =   8.25
  63.       FontStrikethru  =   0   'False
  64.       FontUnderline   =   0   'False
  65.       Height          =   435
  66.       HintBackColor   =   &H0080FFFF&
  67.       HintDelay       =   1000
  68.       HintOffsetX     =   4
  69.       HintOffsetY     =   4
  70.       HintPosition    =   3  'Below Left
  71.       hWndStatusBar   =   MDIMAIN.FRX:20E60
  72.       IgnoreInvisibleButtons=   0   'False
  73.       Left            =   0
  74.       LeftMargin      =   3
  75.       OutlineChildren =   2  'Inset
  76.       ShowDisabledHints=   -1  'True
  77.       ShowDisabledMessages=   -1  'True
  78.       ShowHints       =   -1  'True
  79.       ShowStatusMessage=   4  'Together with Hint
  80.       StatusField     =   0
  81.       Top             =   0
  82.       Width           =   7740
  83.       Begin ComboBox cboFontNames 
  84.          Height          =   300
  85.          Left            =   5400
  86.          Sorted          =   -1  'True
  87.          Style           =   2  'Dropdown List
  88.          TabIndex        =   1
  89.          Top             =   60
  90.          Width           =   1935
  91.       End
  92.       Begin ComboBox cboFontSizes 
  93.          Height          =   300
  94.          Left            =   7920
  95.          Style           =   2  'Dropdown List
  96.          TabIndex        =   0
  97.          Top             =   60
  98.          Width           =   855
  99.       End
  100.       Begin Label Label1 
  101.          AutoSize        =   -1  'True
  102.          BackStyle       =   0  'Transparent
  103.          Caption         =   "Fontname:"
  104.          Height          =   195
  105.          Left            =   4440
  106.          TabIndex        =   3
  107.          Top             =   120
  108.          Width           =   900
  109.       End
  110.       Begin Label Label2 
  111.          AutoSize        =   -1  'True
  112.          BackStyle       =   0  'Transparent
  113.          Caption         =   "Size:"
  114.          Height          =   195
  115.          Left            =   7440
  116.          TabIndex        =   2
  117.          Top             =   120
  118.          Width           =   435
  119.       End
  120.    End
  121.    Begin Menu mnuFile 
  122.       Caption         =   "&File"
  123.       Tag             =   "File operations and exit ToolBarPad"
  124.       Begin Menu mnuFileNew 
  125.          Caption         =   "&New"
  126.          Shortcut        =   ^N
  127.          Tag             =   "Create a new file"
  128.       End
  129.       Begin Menu mnuFileOpen 
  130.          Caption         =   "&Open..."
  131.          Shortcut        =   ^O
  132.          Tag             =   "Open an existing file"
  133.       End
  134.       Begin Menu mnuFileSave 
  135.          Caption         =   "&Save..."
  136.          Shortcut        =   ^S
  137.          Tag             =   "Save the active file"
  138.       End
  139.       Begin Menu mnuFileSaveAs 
  140.          Caption         =   "Save &As..."
  141.          Shortcut        =   ^A
  142.          Tag             =   "Save the active file under a new name"
  143.       End
  144.       Begin Menu mnuFileSep1 
  145.          Caption         =   "-"
  146.       End
  147.       Begin Menu mnuFilePrint 
  148.          Caption         =   "&Print"
  149.          Shortcut        =   ^P
  150.          Tag             =   "Print the active file"
  151.       End
  152.       Begin Menu mnuFilePrintSetup 
  153.          Caption         =   "Print Se&tup..."
  154.          Tag             =   "Set printer options"
  155.       End
  156.       Begin Menu mnuFileSep2 
  157.          Caption         =   "-"
  158.       End
  159.       Begin Menu mnuFileExit 
  160.          Caption         =   "E&xit"
  161.          Tag             =   "Exit ToolBarPad"
  162.       End
  163.    End
  164.    Begin Menu mnuEdit 
  165.       Caption         =   "&Edit"
  166.       Tag             =   "Edit operations"
  167.       Begin Menu mnuEditUndo 
  168.          Caption         =   "&Undo"
  169.          Shortcut        =   ^Z
  170.          Tag             =   "Undo the previous edit action"
  171.       End
  172.       Begin Menu mnuEditSep1 
  173.          Caption         =   "-"
  174.       End
  175.       Begin Menu mnuEditCut 
  176.          Caption         =   "Cu&t"
  177.          Shortcut        =   ^X
  178.          Tag             =   "Move the selected text to the clipboard"
  179.       End
  180.       Begin Menu mnuEditCopy 
  181.          Caption         =   "&Copy"
  182.          Shortcut        =   ^C
  183.          Tag             =   "Copy the selected text to the Clipboard"
  184.       End
  185.       Begin Menu mnuEditPaste 
  186.          Caption         =   "&Paste"
  187.          Shortcut        =   ^V
  188.          Tag             =   "Paste the Clipboard text at the insertion point"
  189.       End
  190.       Begin Menu mnuEditDelete 
  191.          Caption         =   "&Delete"
  192.          Shortcut        =   {DEL}
  193.          Tag             =   "Delete the selected text or the character at the insertion point"
  194.       End
  195.       Begin Menu mnuEditSep2 
  196.          Caption         =   "-"
  197.       End
  198.       Begin Menu mnuEditSelectAll 
  199.          Caption         =   "&Select All"
  200.          Tag             =   "Select the entire text of the active file"
  201.       End
  202.       Begin Menu mnuEditDateTime 
  203.          Caption         =   "&Date/Time"
  204.          Shortcut        =   {F5}
  205.          Tag             =   "Insert the current date and time"
  206.       End
  207.    End
  208.    Begin Menu mnuFind 
  209.       Caption         =   "&Find"
  210.       Tag             =   "Find operations"
  211.       Begin Menu mnuFindFind 
  212.          Caption         =   "&Find..."
  213.          Tag             =   "Find a text pattern"
  214.       End
  215.       Begin Menu mnuFindFindNext 
  216.          Caption         =   "Find &Next"
  217.          Shortcut        =   {F3}
  218.          Tag             =   "Repeat the search"
  219.       End
  220.       Begin Menu mnuFintReplace 
  221.          Caption         =   "&Replace..."
  222.          Shortcut        =   ^R
  223.          Tag             =   "Find a text pattern and replace it with other text"
  224.       End
  225.    End
  226.    Begin Menu mnuWindow 
  227.       Caption         =   "&Window"
  228.       Tag             =   "Window operations"
  229.       WindowList      =   -1  'True
  230.       Begin Menu mnuWindowCascade 
  231.          Caption         =   "&Cascade"
  232.          Shortcut        =   +{F5}
  233.          Tag             =   "Arrange the windows in a cascaded view"
  234.       End
  235.       Begin Menu mnuWindowTile 
  236.          Caption         =   "&Tile"
  237.          Shortcut        =   +{F4}
  238.          Tag             =   "Arrange the windows in a tiled view"
  239.       End
  240.       Begin Menu mnuWindowArrangeIcons 
  241.          Caption         =   "&Arrange Icons"
  242.          Tag             =   "Arrange all iconized windows"
  243.       End
  244.    End
  245. End
  246. Option Explicit
  247.  
  248. Sub ButtonBar1_Click (Button As Integer, Group As Integer, State As Integer)
  249.     Select Case Button
  250.     Case 0: mnuFileNew_Click
  251.     Case 1: mnuFileOpen_Click
  252.     Case 2: mnuFileSave_Click
  253.     Case 3: mnuEditCut_Click
  254.     Case 4: mnuEditCopy_Click
  255.     Case 5: mnuEditPaste_Click
  256.     Case 6: mnuFilePrint_Click
  257.     Case 7:
  258.         If Not frmMain.ActiveForm Is Nothing Then
  259.         frmMain.ActiveForm!txtDocument.FontBold = State
  260.         End If
  261.     Case 8:
  262.         If Not frmMain.ActiveForm Is Nothing Then
  263.         frmMain.ActiveForm!txtDocument.FontItalic = State
  264.         End If
  265.     Case 9:
  266.         If Not frmMain.ActiveForm Is Nothing Then
  267.         frmMain.ActiveForm!txtDocument.FontUnderLine = State
  268.         End If
  269.     Case 10: MsgBox "Help not implemented yet"
  270.     End Select
  271. End Sub
  272.  
  273. Sub cboFontNames_Click ()
  274.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  275.     frmMain.ActiveForm!txtDocument.FontName = cboFontNames.List(cboFontNames.ListIndex)
  276. End Sub
  277.  
  278. Sub cboFontSizes_Click ()
  279.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  280.     frmMain.ActiveForm!txtDocument.FontSize = Val(cboFontSizes.List(cboFontSizes.ListIndex))
  281. End Sub
  282.  
  283. Sub lblAction_Change ()
  284.     If lblAction.Caption = "" Then Exit Sub
  285.     mnuFileSave_Click
  286.     lblAction.Caption = ""
  287. End Sub
  288.  
  289. Sub MDIForm_Load ()
  290. Dim I As Integer
  291.     Screen.MousePointer = 11
  292.  
  293.     WindowState = 2
  294.  
  295.     ButtonBar1.ControlHwnd = cboFontNames.hWnd
  296.     ButtonBar1.ControlHint = "Select font"
  297.     ButtonBar1.ControlMessage = "Select the font for the current and new documents"
  298.     ButtonBar1.ControlHwnd = cboFontSizes.hWnd
  299.     ButtonBar1.ControlHint = "Select fontsize"
  300.     ButtonBar1.ControlMessage = "Select the fontsize for the current and new documents"
  301.  
  302.     ButtonBar1.hWndStatusBar = StatusBar1.hWnd
  303.     ButtonBar1.StatusField = 0
  304.  
  305.     For I = 0 To Screen.FontCount - 1
  306.     cboFontNames.AddItem Screen.Fonts(I)
  307.     If Screen.Fonts(I) = ButtonBar1.FontName Then
  308.         cboFontNames.ListIndex = cboFontNames.NewIndex
  309.     End If
  310.     Next I
  311.     For I = 6 To 40 Step 2
  312.     cboFontSizes.AddItem Format$(I)
  313.     Next I
  314.     cboFontSizes.ListIndex = 2
  315.  
  316.     CheckEditMenu
  317.  
  318.     Screen.MousePointer = 0
  319. End Sub
  320.  
  321. Sub MDIForm_Unload (Cancel As Integer)
  322.     gbMainActive = False
  323.     End
  324. End Sub
  325.  
  326. Sub mnuEditCopy_Click ()
  327.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  328.     ClipBoard.SetText frmMain.ActiveForm!txtDocument.SelText
  329.     CheckEditMenu
  330. End Sub
  331.  
  332. Sub mnuEditCut_Click ()
  333.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  334.     ClipBoard.SetText frmMain.ActiveForm!txtDocument.SelText
  335.     frmMain.ActiveForm!txtDocument.SelText = ""
  336.     CheckEditMenu
  337. End Sub
  338.  
  339. Sub mnuEditDateTime_Click ()
  340.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  341.     frmMain.ActiveForm!txtDocument.SelText = Format$(Now, "mm/dd/yy, hh:mm:ss")
  342. End Sub
  343.  
  344. Sub mnuEditDelete_Click ()
  345.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  346.     frmMain.ActiveForm!txtDocument.SelText = ""
  347.     CheckEditMenu
  348. End Sub
  349.  
  350. Sub mnuEditPaste_Click ()
  351.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  352.     frmMain.ActiveForm!txtDocument.SelText = ClipBoard.GetText()
  353.     CheckEditMenu
  354. End Sub
  355.  
  356. Sub mnuEditSelectAll_Click ()
  357.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  358.     frmMain.ActiveForm!txtDocument.SelStart = 0
  359.     frmMain.ActiveForm!txtDocument.SelLength = Len(frmMain.ActiveForm!txtDocument.Text)
  360.     CheckEditMenu
  361. End Sub
  362.  
  363. Sub mnuEditUndo_Click ()
  364. Dim lRes As Long
  365.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  366.     lRes = SendMessage(frmMain.ActiveForm!txtDocument.hWnd, EM_UNDO, 0, 0)
  367.     CheckEditMenu
  368. End Sub
  369.  
  370. Sub mnuFileExit_Click ()
  371.     If MsgBox("Are you sure you want to quit?", 36) = 6 Then
  372.     Unload Me
  373.     End If
  374. End Sub
  375.  
  376. Sub mnuFileNew_Click ()
  377. Dim frmDoc As New frmDocument
  378.     frmDoc.Caption = "Untitled"
  379.     frmDoc!txtDocument.Text = ""
  380.     frmDoc!txtDocument.FontName = cboFontNames.List(cboFontNames.ListIndex)
  381.     frmDoc!txtDocument.FontSize = Val(cboFontSizes.List(cboFontSizes.ListIndex))
  382.     frmDoc!txtDocument.FontBold = ButtonBar1.ButtonState(7)
  383.     frmDoc!txtDocument.FontItalic = ButtonBar1.ButtonState(8)
  384.     frmDoc!txtDocument.FontUnderline = ButtonBar1.ButtonState(9)
  385.     frmDoc!lblAction.Caption = "set changed = false"
  386.     frmDoc!lblAction.Caption = "set findposition = 0"
  387.     frmDoc.Show
  388. End Sub
  389.  
  390. Sub mnuFileOpen_Click ()
  391. Dim frmDoc As frmDocument
  392. Dim iFree As Integer
  393. Dim sText As String
  394.     cmDialog.Flags = 0
  395.     cmDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
  396.     cmDialog.FilterIndex = 1
  397.     cmDialog.CancelError = True
  398.     On Local Error Resume Next
  399.     cmDialog.Action = 1
  400.     If Err = 0 Then
  401.     iFree = FreeFile
  402.     Open cmDialog.Filename For Input As #iFree
  403.     If Err Then
  404.         MsgBox "Error opening " + cmDialog.Filename, 64
  405.         Exit Sub
  406.     End If
  407.     If LOF(iFree) > 32000 Then
  408.         MsgBox "File too large to edit", 64
  409.         Close #iFree
  410.         Exit Sub
  411.     End If
  412.     sText = Input$(LOF(iFree), iFree)
  413.     Close #iFree
  414.     If Err Then
  415.         MsgBox "Error reading file", 64
  416.         Exit Sub
  417.     End If
  418.     Set frmDoc = New frmDocument
  419.     frmDoc.Caption = cmDialog.Filename
  420.     frmDoc!txtDocument.FontName = cboFontNames.List(cboFontNames.ListIndex)
  421.     frmDoc!txtDocument.FontSize = Val(cboFontSizes.List(cboFontSizes.ListIndex))
  422.     frmDoc!txtDocument.FontBold = ButtonBar1.ButtonState(7)
  423.     frmDoc!txtDocument.FontItalic = ButtonBar1.ButtonState(8)
  424.     frmDoc!txtDocument.FontUnderline = ButtonBar1.ButtonState(9)
  425.     frmDoc!txtDocument.Text = sText
  426.     frmDoc!lblAction.Caption = "set changed = false"
  427.     frmDoc!lblAction.Caption = "set findposition = 0"
  428.     End If
  429. End Sub
  430.  
  431. Sub mnuFilePrint_Click ()
  432.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  433.     On Local Error Resume Next
  434.     Printer.Print frmMain.ActiveForm.txtDocument.Text
  435.     Printer.EndDoc
  436.     If Err Then
  437.     MsgBox "Error during print", 64
  438.     End If
  439. End Sub
  440.  
  441. Sub mnuFilePrintSetup_Click ()
  442.     cmDialog.Flags = &H40
  443.     On Local Error Resume Next
  444.     cmDialog.Action = 5
  445. End Sub
  446.  
  447. Sub mnuFileSave_Click ()
  448.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  449.     If frmMain.ActiveForm.Caption = "Untitled" Then
  450.     mnuFileSaveAs_Click
  451.     Else
  452.     SaveFile frmMain.ActiveForm.Caption, True
  453.     End If
  454. End Sub
  455.  
  456. Sub mnuFileSaveAs_Click ()
  457.     If frmMain.ActiveForm Is Nothing Then Exit Sub
  458.     cmDialog.Flags = &H800 + &H2
  459.     cmDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
  460.     cmDialog.FilterIndex = 1
  461.     If frmMain.ActiveForm.Caption <> "Untitled" Then cmDialog.Filename = frmMain.ActiveForm.Caption
  462.     On Local Error Resume Next
  463.     cmDialog.Action = 2
  464.     If Err = 0 Then SaveFile cmDialog.Filename, False
  465. End Sub
  466.  
  467. Sub mnuFindFind_Click ()
  468.     frmFind.Show
  469. End Sub
  470.  
  471. Sub mnuFindFindNext_Click ()
  472.     FindText
  473. End Sub
  474.  
  475. Sub mnuFintReplace_Click ()
  476.     MsgBox "Replace command not implemented in this demo"
  477. End Sub
  478.  
  479. Sub mnuWindowArrangeIcons_Click ()
  480.     frmMain.Arrange 3
  481. End Sub
  482.  
  483. Sub mnuWindowCascade_Click ()
  484.     frmMain.Arrange 0
  485. End Sub
  486.  
  487. Sub mnuWindowTile_Click ()
  488.     frmMain.Arrange 1
  489. End Sub
  490.  
  491. Sub SaveFile (ByVal sFile As String, bAskOverwrite As Integer)
  492. Dim iFree As Integer
  493.     On Local Error Resume Next
  494.     Screen.MousePointer = 11
  495.     
  496.     If bAskOverwrite Then
  497.     iFree = FreeFile
  498.     Open sFile For Input As #iFree
  499.     If Err = 0 Then
  500.         Close iFree
  501.         Screen.MousePointer = 0
  502.         If MsgBox(sFile + Chr$(13) + Chr$(10) + "File Exists. Overwrite?", 52) <> 6 Then
  503.         cmDialog.Flags = &H800 + &H2
  504.         cmDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
  505.         cmDialog.FilterIndex = 1
  506.         cmDialog.Filename = sFile
  507.         On Local Error Resume Next
  508.         cmDialog.Action = 2
  509.         If Err <> 0 Then
  510.             Exit Sub
  511.         Else
  512.             sFile = cmDialog.Filename
  513.         End If
  514.         End If
  515.     End If
  516.     End If
  517.  
  518.     Screen.MousePointer = 11
  519.     
  520.     iFree = FreeFile
  521.     Open sFile For Output As #iFree
  522.     If Err Then
  523.     Screen.MousePointer = 0
  524.     MsgBox "Error opening file", 64
  525.     Exit Sub
  526.     End If
  527.     Print #iFree, frmMain.ActiveForm!txtDocument.Text
  528.     Close #iFree
  529.     Screen.MousePointer = 0
  530.     If Err Then
  531.     MsgBox "Error writing to file", 64
  532.     Else
  533.     If gcForm Is Nothing Then
  534.         frmMain.ActiveForm!lblAction.Caption = "set changed = false"
  535.     Else
  536.         gcForm!lblAction.Caption = "set changed = false"
  537.     End If
  538.     End If
  539. End Sub
  540.  
  541. Sub StatusBar1_SysMenuBrowse (MenuID As Integer, Message As String)
  542.     Select Case MenuID
  543.     Case Is > 0: Message = "Quit, resize or move this application"
  544.     Case -4096: Message = "Changes the window size"
  545.     Case -4080: Message = "Changes the window position"
  546.     Case -4064: Message = "Reduces the window to an icon"
  547.     Case -4048: Message = "Enlarges the window to full size"
  548.     Case -4000: Message = "Quits ToolBarPad and prompts to save altered files"
  549.     Case -3808: Message = "Restores the window to normal size"
  550.     Case -3792: Message = "Switches to another task"
  551.     End Select
  552. End Sub
  553.  
  554.